#ifndef _AUTO_TIME_SPAN_H_
#define _AUTO_TIME_SPAN_H_

#include <stdio.h>
#include "phstream/gettickcount.h"

struct AutoTimeSpan
{
  AutoTimeSpan(const char* function)
    :m_start_time(gettickcount())
    ,m_functioin(function)
  {

  }

  ~AutoTimeSpan()
  {
#if WIN32
    printf("%s cost time : %I64u, %I64u\n", m_functioin.c_str(), gettickcount()-m_start_time, m_start_time);
#else
    printf("%s cost time : %llu, %llu\n", m_functioin.c_str(), gettickcount()-m_start_time, m_start_time);
#endif
  }

  uint64_t GetTimeSpan()
  {
    return gettickcount() - m_start_time;
  }

private:
  uint64_t m_start_time;
  std::string m_functioin;
};

#endif